<template>
	<view class="container" :style="viewColor">
		<view class="head-wrapper" :style="'top:'+statusBarHeight">
			<view class="head-menu">
				<view class='iconfont icon-xiangzuo' @click="returns"></view>
				<view class="iconfont icon-shouye4" @click="goHome"></view>
			</view>
			<view class="head-title">个人主页</view>
		</view>
		<view class="header" :style="{ 'background-image': userInfo.user_top_back ? `url(${userInfo.user_top_back})` : `url(https://img.jukee.net/def/ed23d202403122235403280.jpg)`, 'padding-top': '200rpx'}">
			<view class="user_wrapper acea-row">
				 <!-- :style="{'margin-top': parseFloat(statusBarHeight ) + 'px'}" -->
				<button open-type="share" style="display: flex;border-radius: 50%;"><image :src="userInfo.avatar || '/static/images/f.png'" class="picture"></image></button>
				<view class="user_text">
					<view class="name acea-row">
						<text>{{userInfo.nickname || ''}}</text>
						<image v-if="userInfo.member_icon" class="level_icon" :src="userInfo.member_icon" alt="">
					</view>
					<view class="user_id">ID: {{userInfo.uid || ''}}</view>
				</view>
				<image class="release_community" v-if="is_my" src="https://ly.jukee.net/uploads/default/20230626/fa67113f019c02055e6b846edad1dda2.png" @click="isPublishPopup = true" />
			</view>
		</view>
		<view class="plant_info acea-row">
			<view class="count_wrapper acea-row" v-if="!is_my">
				<!-- <view class="item" @click="getUserContactInformations({}, 'we_chat_account')">
					<image :src="domain + '/uploads/default/20230715/cd32e4cc83f89f460248767571686772.png'" />
				</view>
				<view class="item" @click="getUserContactInformations({}, 'phone')">
					<image :src="domain + '/uploads/default/20230715/4cebded7d17ad4a92b94c88c14274be5.png'" />
				</view>
				<button class="item" open-type="share" @click="getUserContactInformations({}, 'share')">
					<image :src="domain + '/uploads/default/20230715/92df7fff7fe12a54ac593186c3d2060f.png'" />
				</button>
				<view class="item" @click="getUserContactInformations({}, 'report')">
					<image :src="domain + '/uploads/default/20230715/36150ec648a4a7e06a60e30c0f771b9a.png'" />
				</view> -->
				<view class="item" @click="getUserContactInformations({}, 'we_chat_account')">
					<image src="https://img.jukee.net/def/78281202406092329129210.png" />
				</view>
				<view class="item" @click="getUserContactInformations({}, 'phone')">
					<image src="https://img.jukee.net/def/38c0f202406092329119254.png" />
				</view>
				<view class="item" @click="getUserContactInformations({}, 'message')">
					<image src="https://img.jukee.net/def/31925202406092329133825.png" />
				</view>
				<button class="item" open-type="share" @click="getUserContactInformations({is_user: 1}, 'share')">
					<image src="https://img.jukee.net/def/6018d202406092329121520.png" />
				</button>
			</view>
			<view class="intended-customers" v-else>
				<view class="intended-customers-title">意向客户</view>
				<view class="intended-customers-user" v-if="userInfo.focus">
					<view class="intended-customers-avatar">
						<view v-for="(item, index) in userInfo.intended_customers_user" :key="index" class="intended-customers-avatar-item">
							<image :src=" item.focus.avatar ? item.focus.avatar : '/static/images/f.png'" @click="goUrl('/pages/plantGrass/plant_user/index?id='+item.focus.uid)" />
						</view>
					</view>
					<view class="intended-customers-more" @click="goUrl('/pages/users/promoter-list/index?grade=3')">
						<image :src=" domain + '/uploads/default/20230716/3023bb089153a19402e65cb26e66e708.png'" />
					</view>
				</view>
			</view>
			<view class="business" v-if="!is_my && userInfo.business">{{userInfo.business}}</view>
			<view class="user-address">
				<view class="user-address-detail line1" @click="showMaoLocation">
					<image :src=" domain + '/uploads/def/20230716/d975e0044517f8b55be61008a6377532.png'" mode="widthFix"/>
					{{userInfo.province || ''}}{{userInfo.city || ''}}{{userInfo.district || ''}}{{userInfo.address || ''}}
				</view>
				<view class="user-address-btn" @click="showMaoLocation" v-if="userInfo.onsite_svc == 1">
					上门服务
				</view>
			</view>
		</view>
		<view class="tabNav">
			<div class="tabNav-item" v-for="(item, index) in searchList" :key="index" @click="searchContent(item.type, index)" v-if="index != 4 || is_community_video_start == 1">
				<div class="tabNav-item-name" :class="searchType == item.type ? 'on' : ''">{{item.name}}</div>
			</div>
		</view>
		<view class="search-list-content">
			<!-- <view class="common-content-margin" v-if="is_my">
				<view class="common-head">
					<view class="common-title"><view class="common-title-name">{{searchList[index].name}}广场</view></view> -->
					<!-- <view class="common-head-more" @click="goUrl('/pages/extends/community/community_demand')"><image :src="domain + '/uploads/def/20230702/97c18c51de8da55ee03c7f5b0d3c03f8.png'" /></view> -->
				<!-- </view>
				<template  v-if="recommendDemandData.list" >
					<demand :list="recommendDemandData.list"></demand>
				</template>
			</view> -->
			<template v-if="is_my || searchType != 1">
				<view class="search-list-data" v-if="list.length">
					<service :list="list" v-if="searchType == 1 && is_my" :type="2" :isMy="is_my"></service>
					<circleItem :list="list" v-if="searchType == 5"></circleItem>
					<videoList :list="list" v-if="searchType == 2"></videoList>
					<demand :list="list" v-if="searchType == 3" :type="2":isMy="is_my"></demand>
					<userProduct :list="list" v-if="searchType == 6"></userProduct>
				</view>
				<emptyPage v-else title="正在加载中···" :mTop="0"></emptyPage>
			</template>
			<template v-else>
				<view class="navTabBox">
					<view class="longTab">
						<view class="tab-item" v-for="(item,index) in service_head" :key="index" :class="{'on':index == service_check}" @click="changeServiceCheck(index)">
							<text>{{item.title}}</text>
						</view>
					</view>
				</view>
				<view class="servie-introduce" v-if="service_check == 0">
					<template v-if="userInfo.user_service && userInfo.user_service.content">
						<view class="font-size36-bold" style="margin-bottom: 20rpx;">{{userInfo.user_service.title || ''}}</view>
						{{userInfo.user_service.content || '暂无公司介绍'}}
						<template v-if="userInfo.user_service.pic.length">
							<view style="margin-top: 20rpx;"></view>
							<image v-for="(v, k) in userInfo.user_service.pic" :key="k" :src="v" style="width: 100%;" mode="widthFix" />
						</template>
					</template>
					<template v-else>
						{{userInfo.service || '暂无公司介绍'}}
						<template v-if="userInfo.service_pics && userInfo.service_pics.length">
							<view style="margin-top: 20rpx;"></view>
							<image v-for="(v, k) in userInfo.service_pics" :key="k" :src="v" style="width: 100%;" mode="widthFix" />
						</template>
					</template>
				</view>
				<view class="recommend-title" v-if="service_check == 0">他的行业</view>
				<view class="servie-label" v-if="service_check == 0">
					{{userInfo.label.label_name || '暂无选择行业'}}
				</view>
				<view class="servie-introduce" style="text-align: center;" v-if="userInfo.user_service && userInfo.user_service.share_posters && service_check == 0">
					<view><image :src="userInfo.user_service.share_posters" style="width: 240rpx;" mode="widthFix" /></view>
					<view><text style="color: #FFE60F;">{{userInfo.user_service.title}}</text> 专属小程序二维码</view>
				</view>
				<service :list="list" :type="2" v-if="service_check == 1"></service>
			</template>
			
			<view class="recommend-title" v-if="!is_my && is_recommend_list">更多相似需求</view>
			<view class="search-list-data" v-if="recommendList.length > 0 && !is_my">
				<demand :list="recommendList" v-if="searchType == 3" :type="2"></demand>
			</view>
			
			<!-- 非个人中心 服务选项 公司介绍展示 -->
			<view class="recommend-title" v-if="!is_my && searchType == 1 && service_check == 0 && list.length">更多服务商</view>
			<view class="search-list-data" v-if="!is_my && searchType == 1 && service_check == 0 && list.length">
				<service :list="list" :type="3"></service>
				<view class="service_settle_btn">
					<view class="service_settle_button font-size32-bold" @click="goUrl('/pages/extends/user_service/index')">我要入驻</view>
				</view>
			</view>
		</view>
		<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
		<!-- 手机号微信查看弹窗 -->
		<view class="popup_user_contact" v-show="is_popup_user_contact" @click="is_popup_user_contact=false">
			<view class="popup_user_contact_c">
				<view class="popup_user_contact_h">
					<view class="popup_user_contact_t">提示</view>
					<view class="popup_user_contact_u">{{popup_user_contact_type == 'phone' ? '电话：' : '微信号：'}}<text>{{popup_user_contact}}</text></view>
				</view>
				<view class="popup_user_contact_b">
					<view class="popup_user_contact_close" @click="is_popup_user_contact=false">取消</view>
					<view class="popup_user_contact_copy" @click="copyUserContact">复制</view>
				</view>
			</view>
		</view>
		<!-- 二维码弹窗end -->
		<!-- 购买查看会员次数弹窗 -->
		<paymentData :payMode="payMode" :pay_close="pay_close" :is-call="true" @onChangeFun="onChangeFun" :payTitle="'查看会员联系方式次数'" :payGroupName="'user_contact_information'" :userCount="0" :unit="'个'" :rechargeType="1"></paymentData>
		<publishPopup :isPublishPopup="isPublishPopup" @closePublishPopup="closePublishPopup"></publishPopup>
		
		<!-- 升级VIP弹窗 -->
		<view class="user_vip_tips" v-if="user_vip_tips">
			<view class="user_vip_back"></view>
			<view class="user_vip_content">
				<view class="user_vip_close" @click="user_vip_tips = false">
					<image src="https://ly.jukee.net/uploads/default/20230803/8d5635ef7c1504bfadbd85f0a04270cc.png" />
				</view>
				<view class="user_vip_icon">
					<image src="https://img.jukee.net/def/3902e202311271626269626.png" />
				</view>
				<view class="user_vip_title font-size32-bold">成为VIP会员</view>
				<view class="user_vip_tit font-size36-bold" style="font-size: 46rpx;">无限添加客户微信<br/>查看所有客户联系方式</view>
				<view class="user_vip_messag">更多权益请在 “我的” 会员中心查看</view>
				<view class="user_vip_btn" @click="goUrl('/pages/annex/vip_paid/index')">确定</view>
			</view>
		</view>
		
		<!-- 发布服务成功弹窗 -->
		<view class="add_community" v-if="is_add_community">
			<view class="add_community_content">
				<view class="add_community_close" @click="is_add_community = false">
					<image src="https://ly.jukee.net/uploads/default/20230803/8d5635ef7c1504bfadbd85f0a04270cc.png" />
				</view>
				<view class="add_community_icon">
					<image src="https://img.jukee.net/def/84362202312222304174974.png" />
				</view>
				<view class="add_community_tips font-size36-bold">
					恭喜，发布成功
				</view>
				<view class="add_community_select">
					<view class="add_community_b" @click="goUrl('/pages/users/user_community/index?type=1')">管理信息</view>
					<view class="add_community_b" @click="goHome">我的发布</view>
					<view class="add_community_b" @click="goUrl('/pages/extends/circle_create/list?type=4&community_id='+add_community_id)">所发圈子</view>
				</view>
				<view class="add_community_tit">首页热榜置顶</view>
				<!-- <view class="add_community_key">所有用户每天看见我的广告</view> -->
				<view class="add_community_pro">
					<view class="add_community_item" :class="add_community_item == index ? 'add_community_item_on' : ''" v-for="(item, index) in add_community_list" :key="index" @click="add_community_item = index">
						<view class="add_community_day">置顶{{item.number}}天</view>
						<view class="add_community_price"><text>¥</text>{{item.price}}</view>
					</view>
				</view>
				<view class="add_community_btn" @click="addCommunityPay">我要置顶</view>
			</view>
		</view>
		<payment :payMode="payMode" :pay_close="pay_close2" :is-call="true" @onChangeFun="onChangeFun" :totalPrice="totalPrice"></payment>
		<view class="back_popup flex-aj-center" @click="wechat_qrcode_img = ''" v-if="wechat_qrcode_img">
			<image :src="wechat_qrcode_img" style="width: 500rpx;border-radius: 20rpx;" mode="widthFix" @click="previewImage(wechat_qrcode_img)">
		</view>
	</view>
</template>

<script>
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	import WaterfallsFlow from '@/components/plantWaterfallsFlow/WaterfallsFlow.vue'
	import { userInfoApi, followAuthorApi, incCommunityCountStart } from '@/api/community.js';
	import { getUserInfo, getUserContactInformation, rechargeWechat } from '@/api/user.js';
	import { getListCircle, recommendCommunity } from '@/api/circle.js'
	import { addServiceStoreLog } from '@/api/store.js'
	import { getUserProductList } from "@/api/user_product"
	import { getSystemConfig, getUserServiceList, getSystemGroupData } from '@/api/api.js'
	import { mapGetters } from "vuex";
	import { configMap } from '@/utils';
	import authorize from '@/components/Authorize';
	import paymentData from '@/components/payDataList';
	import payment from '@/components/payment';
	import service from '@/components/service/index.vue';
	import demand from '@/components/demand/index.vue';
	import circleItem from '@/components/circle_item/index.vue';
	import videoList from '@/components/videoList/index.vue';
	import userProduct from '@/components/userProduct/index.vue';
	import emptyPage from '@/components/emptyPage.vue'
	import publishPopup from '@/components/publishPopup';
	import { checkPhone } from '@/utils/validate.js';
	import { HTTP_REQUEST_URL } from '@/config/app';
	const app = getApp();
	export default {
		components: {
			authorize,
			WaterfallsFlow,
			paymentData,
			payment,
			service,
			demand,
			circleItem,
			videoList,
			userProduct,
			emptyPage,
			publishPopup
		},
		data() {
			return {
				domain: HTTP_REQUEST_URL,
				statusBarHeight: statusBarHeight, //系统导航条高度
				loadTitle: '加载更多',
				loading: true,
				isShowAuth: false, //是否隐藏授权
				isAuto: false, //没有授权的不会自动授权
				userInfo: {},
				myUserInfo: {},
				tab: 0,
				uid: '',
				popup_user_contact: '',
				is_popup_user_contact: false,
				popup_user_contact_type: '',
				pay_close: false,
				pay_close2: false,
				payMode: [{
					name: '微信支付',
					icon: 'icon-weixinzhifu',
					value: 'wechat',
					title: '微信快捷支付',
					payStatus: true
					}
					// #ifdef H5 ||APP-PLUS
					,
					{
					name: '支付宝支付',
					icon: 'icon-zhifubao',
					value: 'alipay',
					title: '支付宝支付',
					payStatus: true
					}
					// #endif
					,
					{
						name: "余额支付",
						icon: "icon-yuezhifu",
						value: 'balance',
						title: '可用余额:',
						number: 0,
						payStatus: this.$store.getters.globalData.yue_pay_status
					}
				],
				searchList: [
					{
						name: '需求',
						type: 3,
					},
					{
						name: '服务',
						type: 1,
					},
					{
						name: '圈子',
						type: 5,
					},
					{
						name: '好货',
						type: 6,
					},
					{
						name: '视频',
						type: 2,
					}
				],
				searchType: 1,
				index: 0,
				list: [],
				recommendList: [],
				is_recommend_list: false,
				page: 1,
				limit: 10,
				is_my: false,
				is_type: 1,
				share_reward: 0,
				is_service: 0, // 0不是服务商 1服务商
				service_head: [
					{title: '公司介绍'},
					{title: '捞鱼圈'}
				],
				service_check: 1,
				isPublishPopup: false,
				user_vip_tips: false, // 提醒用户开启VIP弹窗
				is_add_community: false, //首次发布服务弹窗
				add_community_id: 0, // 首次发布服务ID
				add_community_list: [], // 首次发布服务推广列表
				add_community_item: -1, // 首次发布服务推广选项
				totalPrice: 0,
				wechat_qrcode_img: '', // 微信二维码
			}
		},
		created() {},
		computed: configMap({is_community_video_start: 0}, mapGetters(['isLogin', 'viewColor', 'keyColor'])),
		watch: {},
		onLoad(options) {
			if(options.scene) {
				options = this.$util.getUrlParams(decodeURIComponent(options.scene));
				options.is_service = 1;
			}
			let that = this;
			that.uid = options.id;
			that.is_type = options.is_type || '';
			that.is_service = options.is_service || 0;
			if (that.is_type == 1 && options.add) {
				that.is_add_community = true;
				that.add_community_id = options.add;
				getSystemGroupData({name: 'community_promotion'}).then(res=>{
          const list = res.data.list
        
					that.add_community_list = list;
				})
			}
			if(options.is_service == 1) {
				options.searchType = 1;
			}
			if (that.isLogin) {
				that.my_uid = that.$Cache.get('UID');
				if(that.my_uid == that.uid) {
					that.is_my = true;
				}else{
					addServiceStoreLog({uid:that.uid, msn: '我查看了你的服务主页'}).then(res=>{
						
					})
				}
				if(!that.is_my) {
					let searchList = [
						{
							name: '需求',
							type: 3,
						},
						{
							name: '服务',
							type: 1,
						},
						{
							name: '圈子',
							type: 5,
						},
						{
							name: '好货',
							type: 6,
						},
						{
							name: '视频',
							type: 2,
						},
					];
					if(options.searchType && options.searchType == 1) {
						// 默认展示需求
						that.searchType = parseInt(options.searchType)
						that.index = 1;
						that.service_check = 1;
					} else {
						that.searchType = 1;
					}
					that.$set(that, 'searchList', searchList);
				}
				if (options.community_id) {
					// 增加服务点击量
					incCommunityCountStart(options.community_id)
				}
				that.getAuthorInfo(that.uid);
				that.getUserInfo();
				that.getList();
				that.getConfigData();
			} else {
				this.$util.Tips({title:'请先登录'}, {tab: 1, url: '/pages/user/index'})
			}
		},
		onShow() {},
		onReady() {},
		mounted: function() {},
		methods: {
			previewImage(url) {
				uni.previewImage({
					urls: [url],
					longPressActions :{
						itemList:['保存图片']
					},
				})
			},
			getConfigData() {
				let that = this;
				getSystemConfig({name:'serv_share_reward'}).then(res=>{
					that.share_reward = res.message;
					if(that.is_type == 1 || that.is_type == 3) {
						/* uni.showModal({
							title: '温馨提示',
							content: '分享可获得'+that.share_reward+'鱼币奖励',
							confirmText: '分享',
							success: function (res) {
								if (res.confirm) {
									uni.share({
										type: 0,
										scene: 'WXSceneSession',
										href: '/pages/index/index?spid='+that.my_uid,
										success(res) {
										  // 分享成功
										  console.log('分享成功', res);
										},
										fail(err) {
										  // 分享失败
										  console.log('分享失败', err);
										}
									});
								} else if (res.cancel) {
									console.log('取消');
								}
							}
						}); */
					}
				})
			},
			// 授权回调
			onLoadFun() {
				this.isShowAuth = false;
				return uni.switchTab({
					url: '/pages/user/index'
				});
			},
			// 授权关闭
			authColse: function(e) {
				this.isShowAuth = e
			},
			// 打开授权
			authOpen: function() {
				let that = this;
				if (that.isLogin === false) {
					this.isAuto = true;
					this.isShowAuth = true
				}
			},
			// 服务公司结合搜啊捞鱼圈切换
			changeServiceCheck(index) {
				let that = this;
				that.service_check = index;
				that.searchContent(that.searchType, that.index)
			},
			// 切换搜索内容类型
			searchContent(type, index) {
				this.is_recommend_list = false;
				// if(this.searchType == type) return false;
				this.searchType = type;
				this.index = index;
				// if(type == 1 && !this.is_my) return false;
				this.loading = true;
				this.page = 1;
				this.list = [];
				this.getList();
			},
			getList: function() {
				let that = this;
				if(!that.loading) return false;
				let data = {
					page: that.page,
					limit: that.limit,
					uid: that.uid,
				}
				if(that.searchType == 1 && that.service_check == 0 && !that.is_my) {
					data.not_uid = data.uid;
					data.uid = '';
					// 服务 公司介绍
					getUserServiceList(data).then(res=>{
						that.list = that.list.concat(res.data.list)
						that.loading = res.data.list.length >= that.limit
						that.page++
					})
				} else if([1,2,3].includes(that.searchType)) {
					// 搜索需求
					data.is_type = that.searchType
					recommendCommunity(data).then(res => {
						if(res.status == 200)
						{
							that.list = that.list.concat(res.data.list)
							that.loading = res.data.list.length >= that.limit;
							that.page++;
							if(that.searchType == 3 && res.data.count < that.limit) {
								recommendCommunity({page: 1, limit: 6, not_uid: that.uid, is_type: 3}).then(res => {
									if(res.data.count) {
										that.is_recommend_list = true;
										that.recommendList = res.data.list
									}
								})
							}
						}
					}).catch(err=>{
						that.$util.Tips({title: err});
					})
					
				} else if(that.searchType == 5) {
					// 搜索圈子
					data.is_join_circle = 1;
					getListCircle(data).then(res => {
						if(res.status == 200)
						{
							that.list = that.list.concat(res.data.list)
							that.loading = res.data.list.length >= that.limit;
							that.page++
						}
					}).catch(err=>{
						that.$util.Tips({title: err});
					})
				} else if(that.searchType == 6) {
					// 搜索好货
					data.status = 1;
					data.is_show = 1;
					getUserProductList(data).then(res=>{
						that.list = that.list.concat(res.data.list)
						that.loading = res.data.list.length >= that.limit;
						that.page++
					}).catch(err=>{
						that.$util.Tips({title: err});
					})
				}
			},
			/*获取用户信息*/
			getAuthorInfo(id){
				let that = this;
				userInfoApi(id).then(res => {
					that.userInfo = res.data
				});
			},
			// 关注作者
			followAuthor: function() {
				if (this.isLogin === false) {
					this.isAuto = true;
					this.isShowAuth = true
				} else {
					let status = this.userInfo.is_start ? false : true
					followAuthorApi(this.userInfo.uid,{status: status}).then(res => {
						if (res.status === 200) {
							this.userInfo.is_start = this.userInfo.is_start ? false : true
						}
						this.$util.Tips({
							title: res.message
						});
					});
				}
			},
			/**
			 * 查看会员联系方式
			 * @param {Object} uid
			 * @param {Object} contact_information
			 */
			getUserContactInformations({}, contact_information) {
				if(!this.isLogin) return this.$util.Tips({title:'请先登录'}, {tab: 1, url: '/pages/user/index'})
				let that = this;
				let uid = that.uid;
				if(contact_information == 'phone' || contact_information == 'we_chat_account'){
					getUserContactInformation({uid, contact_information}).then(res=>{
						if(contact_information == 'phone' && checkPhone(res.message)) {
							return uni.makePhoneCall({
								phoneNumber: res.message // 替换为你想拨打的电话号码
							  }).then(() => {
								console.log('拨打电话成功')
							  }).catch((error) => {
								console.log('拨打电话失败', error)
							  })
						} else {
							if (res.data && res.data.is_img == 1) {
								that.wechat_qrcode_img = res.data.data;
							} else {
								if (res.message) {
									that.popup_user_contact = res.message || '暂未设置该联系方式'
									that.popup_user_contact_type = contact_information;
									that.is_popup_user_contact = true;
								} else {
									uni.showModal({
										title: '温馨提示',
										content: '等待对方验证',
										showCancel: false,
									})
								}
							}
						}
					}).catch(err=>{
						if(err == '次数不足') {
							that.user_vip_tips = true;
							// that.pay_close = true;
						} else {
							that.$util.Tips({title: err});
						}
					})
				} else if (contact_information == 'message') {
					if (this.myUserInfo.is_svip > 0) {
						this.goUrl('/pages/chat/customer_list/chat?userId='+this.userInfo.uid)
					} else {
						that.user_vip_tips = true;
					}
				}else if(contact_information == 'share') {
					uni.share({
						type: 0,
						scene: 'WXSceneSession',
						title: that.userInfo.nickname+'个人主页',
						imageUrl: that.userInfo.avatar,
						href: '/pages/plantGrass/plant_user/index?id='+that.uid+'&is_service=1',
						success(res) {
						  // 分享成功
						  console.log('分享成功', res);
						},
						fail(err) {
						  // 分享失败
						  console.log('分享失败', err);
						}
					  });
				}else if(contact_information == 'report') {
					that.$util.Tips('/pages/extends/user_report/index?type=3&link_id='+that.uid)
				}
			},
			copyUserContact() {
				let that = this;
				that.is_popup_user_contact = false;
				if(this.popup_user_contact && this.popup_user_contact!='暂未设置该联系方式') {
					uni.setClipboardData({
					  data: that.popup_user_contact,
					  success: function () {
						return that.$util.Tips({title:'复制成功'});
					  }
					})
				}else{
					return this.$util.Tips({title:'复制失败'});
				}
			},
			/**
			 * 获取个人用户信息
			 */
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					that.myUserInfo = res.data;
					// #ifdef H5 ||APP-PLUS
					that.payMode[2].number = res.data.now_money;
					// #endif
					// #ifndef H5 ||APP-PLUS
					that.payMode[1].number = res.data.now_money;
					// #endif
				});
			},
			onChangeFun: function(e) {
				let opt = e;
				let action = opt.action || null;
				let value = opt.value != undefined ? opt.value : null;
				action && this[action] && this[action](value);
			},
			payClose: function() {
				this.pay_close = false;
				this.pay_close2 = false;
			},
			payCheck(paytype) {
				let that = this;
				let number = 0;
				let order = that.add_community_list[that.add_community_item]
				let type = ''
				if (paytype == 'wechat' || paytype == 'routine') {
					// #ifdef H5
					type = this.$wechat.isWeixin() ? 'weixin' : 'h5';
					// #endif
					// #ifdef APP-PLUS
					type = 'weixin';
					// #endif
					// #ifdef MP
					type = 'routine';
					// #endif
				} else if (paytype == 'balance') {
					type = 'balance';
				}else if(paytype == 'alipay'){
					// #ifndef MP
					type = 'alipay';
					// #endif					
					// #ifdef MP
					type = 'alipayQr';
					// #endif
				}
				// console.log(type, paytype, order)
				if (!order || !order.group_data_id) return that.$util.Tips({
					title: '请选择要支付的订单'
				});
				if (paytype == 'balance' && parseFloat(number) < parseFloat(order.price)) return that.$util.Tips({
					title: '余额不足！'
				});
				uni.showLoading({
					title: '支付中'
				});
				rechargeWechat({
					type: type,
					recharge_id: order.group_data_id,
					recharge_type: 3, // 1充值查看会员联系方式次数
					extend: {
						community_id: that.add_community_id
					},
					// #ifdef H5
					return_url: 'http://'+window.location.host+'/pages/users/index',
					// #endif
				}).then(res => {
					let status = res.data.type,
						jsConfig = res.data.config,
						goPages = '/pages/users/order_list/index';
					switch (status) {			
						case 'ORDER_EXIST':
						case 'EXTEND_ORDER':
						case 'PAY_ERROR':
						case 'error':
							uni.hideLoading();
							that.payClose();
							return that.$util.Tips({
								title: res.message
							});							
							break;
						case 'success':
							uni.hideLoading();
							that.payClose();				
							return that.$util.Tips({
								title: '支付成功',
								icon: 'success'
							});
							break;
						case 'alipay':
						case 'alipayQr':
							uni.hideLoading();
							that.payClose();
							return 								
							break;	
						// #ifndef MP
						case "wechat":
						case "weixin":
						case "weixinApp":
							jsConfig.timeStamp = jsConfig.timestamp;
							// #ifndef APP-PLUS
							that.$wechat.pay(jsConfig).then(res => {	
								that.payClose();
								uni.hideLoading();
								return that.$util.Tips({
									title: '支付成功',
									icon: 'success'
								});
							}).catch(res => {
								if (res.errMsg == 'chooseWXPay:cancel'){
									if(that.isCall){
										return that.$util.Tips({
											title: '取消支付'
										});
									}else{
										return that.$util.Tips({
											title: '取消支付'
										}, {	
											tab: 5,
											url: goPages
										});
									}
								} 
							})
							// #endif
							// #ifdef APP-PLUS
							let mp_pay_name=''
							if(uni.requestOrderPayment){
								mp_pay_name='requestOrderPayment'
							}else{
								mp_pay_name='requestPayment'
							}
							uni[mp_pay_name]({
								provider: 'wxpay',
								orderInfo: jsConfig,
								success: (e) => {
									that.payClose();
									return that.$util.Tips({
										title: '支付成功',
										icon: 'success'
									}, {	
										tab: 5,
										url: goPages
									});
								},
								fail: (e) => {
									if(that.isCall){
										return that.$util.Tips({
											title: '取消支付'
										});
									}else{
										return that.$util.Tips({
											title: '取消支付'
										}, {	
											tab: 5,
											url: goPages
										});
									}
								},
								complete: () => {
									uni.hideLoading();
								},
							});
							// #endif
							break;
						// #endif
						// #ifdef MP
						case "routine":
							jsConfig.timeStamp = jsConfig.timestamp;
							that.toPay = true;
							let mp_pay_name=''
							if(uni.requestOrderPayment){
								mp_pay_name='requestOrderPayment'
							}else{
								mp_pay_name='requestPayment'
							}
							uni[mp_pay_name]({
								...jsConfig,
								success: function(res) {
									uni.hideLoading();
									that.payClose();
									if (that.BargainId || that.combinationId || that.pinkId || that.seckillId)
										return that.$util.Tips({
											title: '支付成功',
											icon: 'success'
										}, {	
											tab: 5,
											url: goPages
										});
									
									return that.$util.Tips({
										title: '支付成功',
										icon: 'success'
									});
								},
								fail: function(e) {
									uni.hideLoading();
									that.payClose();
									return that.$util.Tips({
										title: '取消支付'
									});
								},
								complete: function(e) {
									uni.hideLoading();									
									//关闭当前页面跳转至订单状态
									if (res.errMsg == 'requestPayment:cancel') return that.$util.Tips({
										title: '取消支付'
									});
									that.payClose();
								},
							})
							break;
						// #endif
						case "balance":
							uni.hideLoading();
							that.payClose();
							//余额不足
							return that.$util.Tips({
								title: res.message
							});
							break;
						// #ifdef H5
						case 'h5':
							let host = window.location.protocol+"//"+window.location.host;
							let url = `${host}${goPages}`
							let eUrl = encodeURIComponent(url)
							let jsurl = jsConfig.mweb_url || jsConfig.h5_url
							let locations = `${jsurl}&redirect_url=${eUrl}`
							setTimeout(() => {
								location.href = locations;
							}, 100);
							break;
						// #endif	
							
						// #ifdef APP-PLUS
						case 'alipayApp':
							uni.requestPayment({
								provider: 'alipay',
								orderInfo: jsConfig,
								success: (e) => {
									that.payClose();
									return that.$util.Tips({
										title: '支付成功',
										icon: 'success'
									}, {	
										tab: 5,
										url: goPages
									});
							
								},
								fail: (e) => {
									return that.$util.Tips({
										title: '取消支付'
									});
								},
								complete: () => {
									uni.hideLoading();
								},
							});
						break;
						// #endif
					}
				}).catch(err => {
					uni.hideLoading();
					return that.$util.Tips({
						title: err
					});
				})
			},
			// 后退
			returns: function() {
				uni.navigateBack()
			},
			// 首页
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			},
			goUrl(url) {
				if(!url) return false;
				this.$util.Tips(url);
			},
			addCommunityPay() {
				let that = this;
				if (that.add_community_item < 0) {
					return that.$util.Tips({title: '请选择服务首页热榜置顶'})
				}
				that.totalPrice = that.add_community_list[that.add_community_item].price;
				that.pay_close2 = true;
			},
			//查看地图
			showMaoLocation() {
				let that = this;
				let lat = that.userInfo.lat,
					long = that.userInfo.lng;
				if (!lat || !long)
					return this.$util.Tips({
						title: '该用户暂未设置访问定位！'
					});
				//#ifdef H5
				if (this.$wechat.isWeixin() === true) {
					this.$wechat
						.seeLocation({
							latitude: Number(lat),
							longitude: Number(long),
							name: this.store.mer_name,
							address: this.store.mer_address ? this.store.mer_address : ''
						})
						.then(res => {
							console.log('success');
						});
				} else {
					//#endif
					uni.openLocation({
						latitude: parseFloat(lat),
						longitude: parseFloat(long),
						scale: 8,
						geocode: true,
						name: that.userInfo.nickname,
						address: (that.userInfo.province || '') + (that.userInfo.city || '') + (that.userInfo.district || '') + (that.userInfo.address || ''),
						success: function(res) {
							console.log(res);
						}
					});
					// #ifdef H5
				}
				//#endif
			},
			closePublishPopup() {
				this.isPublishPopup = false;
			},
		},
		onReachBottom() {
			this.getList();
		},
		onPullDownRefresh(){},
		// 滚动监听
		onPageScroll(e) {
			// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
			uni.$emit('scroll');
		},
		// #ifdef MP
		onShareAppMessage: function() {
			let that = this;
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			});
			// ((that.service_check == 0 && userInfo.user_service) ? that.userInfo.user_service.content : that.userInfo.service) || that.userInfo.nickname+'的微店，这里有ta的服务、好货、圈子、视频',
			return {
				title: that.userInfo.nickname+'的微店，这里有ta的服务、好货、圈子、视频',
				imageUrl: that.userInfo.user_top_back || that.userInfo.avatar || 'https://img.jukee.net/def/6c0e4202309031609147410.png',
				path: '/pages/plantGrass/plant_user/index?id='+that.uid+'&is_service=1&spid=' + that.$Cache.get('UID')
			}
		},
		onShareTimeline: function() {
			let that = this;
			return {
				title: that.share_title,
				query: {
					spid: that.$Cache.get('uid')
				},
				imageUrl: ''
			};
		},
		// #endif
	}
</script>

<style lang="scss" scoped>
.container{
	// background: #ffffff;
	min-height: 100vh;
}
.header{
	width: 750rpx;
	// height: 546rpx;
	padding: 56rpx 30rpx 100rpx;
	background-repeat: no-repeat;
	background-size: 100%;
	margin-bottom: -100rpx;
	.user_wrapper{
		align-items: center;
		.image,uni-image,image{
			width: 140rpx;
			height: 140rpx;
			border-radius: 100%;
			border: 4rpx solid #ffffff;
		}
		.user_text{
			margin-left: 22rpx;
			color: #000;
			.name{
				font-size: 34rpx;
				font-weight: bold;
				align-items: center;
			}
			.user_id{
				margin-top: 16rpx;
				font-size: 26rpx;
			}
			.level_icon{
				width: 34rpx;
				height: 32rpx;
				margin: 4rpx 0 0 6rpx;
				border: none;
			}
		}
		.release_community {
			margin-left: auto;
			width: 120rpx;
			height: 120rpx;
		}
	}
	
	.follow_btn{
		color: #ffffff;
		font-size: 26rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 146rpx;
		height: 62rpx;
		background-color: transparent;
		background-image: linear-gradient(270deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
		border-radius: 33rpx;
		.iconfont{
			font-size: 16rpx;
			margin-right: 12rpx;
		}
		.icon-fabu{
			font-size: 24rpx;
		}
		&.focused{
			background: transparent;
			color: #FFFFFF;
			border: 1px solid #FFFFFF;
		}
	}
}
.plant_info{
	margin: 30rpx 50rpx 0;
	align-items: center;
	justify-content: space-between;
	box-shadow: 4rpx 4rpx 50rpx 0rpx rgba(125,124,116,0.1);
	border-radius: 12rpx;
	background-color: #fff;
	padding: 30rpx;
	.count_wrapper{
		color: #FFFFFF;
		font-size: 24rpx;
		width: 100%;
		justify-content: space-between;
		.item{
			background-color: #FFE103;
			border-radius: 50%;
			text-align: center;
			display: flex;
			image {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				margin: 5rpx
			}
		}
	}
	.intended-customers {
		// margin-top: 40rpx;
		width: 100%;
		.intended-customers-title {
			font-size: 30rpx;
			font-weight: 500;
			color: #323232;
			line-height: 42rpx;
		}
		.intended-customers-user {
			display: flex;
			flex-wrap: nowrap;
			padding: 20rpx 0;
			align-items: center;
			width: 100%;
			.intended-customers-avatar {
				display: flex;
				flex-wrap: nowrap;
				overflow-x: auto;
				grid-gap: 12rpx;
				margin-right: 20rpx;
				.intended-customers-avatar-item {
					width: 54rpx;
					height: 54rpx;
					image {
						width: 54rpx;
						height: 54rpx;
						border-radius: 50%;
					}
				}
				
			}
			.intended-customers-more {
				width: 50rpx;
				height: 50rpx;
				margin-left: auto;
				text-align: center;
				display: flex;
				align-items: center;
				justify-content: center;
				image {
					width: 10rpx;
					height: 22rpx;
					display: block;
				}
			}
		}
	}
	.business {
		margin-top: 30rpx;
	}
	.user-address {
		display: flex;
		flex-wrap: nowrap;
		overflow-y: auto;
		align-items: center;
		width: 100%;
		margin-top: 20rpx;
		.user-address-detail {
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			font-size: 26rpx;
			font-weight: 400;
			color: #323232;
			line-height: 40rpx;
			flex: 1;
			overflow-x: auto;
			white-space: nowrap;
			margin-right: 12rpx;
			image {
				width: 24rpx;
				height: 26rpx;
				display: inline-table;
				margin-right: 12rpx;
			}
		}
		.user-address-btn{
			background: #FFE103;
			border-radius: 32rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: #1C211D;
			line-height: 40rpx;
			padding: 12rpx 30rpx;
			margin-left: 100rpx;
		}
	}
}
.tabNav {
	padding: 30rpx 0;
	display: flex;
	.tabNav-item {
		flex: 1;
		text-align: center;
		.tabNav-item-name {
			font-size: 34rpx;
			font-weight: 500;
			color: #323232;
			line-height: 48rpx;
			position: relative;
		}
		.on {
			font-size: 38rpx;
			font-weight: 500;
			color: #323232;
			line-height: 52rpx;
			&::after{
				content: '';
				transition: .5s;
				display: inline-block;
				width: 90%;
				height: 15rpx;
				background: url('http://ly.jukee.net/uploads/default/20230629/335f742a6bee3fdbc75d81c86c6ba350.png') center / contain no-repeat;
				position: absolute;
				left: 5%;
				bottom: -20rpx;
			}
		}
	}
}
.common-content-margin {
	// padding: 40rpx 30rpx 0;
	// background-color: #fff;
}
.common-head {
	display: flex;
	flex-wrap: initial;
	align-items: center;
	.common-title {
		margin-right: auto;
		position: relative;
		&:before {
			content: "";
			display: inline-block;
			width: 100%;
			height: 20rpx;
			background-color: #FFE103;
			position: absolute;
			bottom: 0rpx;
		}
		.common-title-name {
			font-size: 40rpx;
			font-weight: 500;
			color: #2C2C2C;
			line-height: 56rpx;
			position: relative;
		}
	}
	.common-children-t {
		display: flex;
		align-items: center;
		.common-children-title {
			font-size: 32rpx;
			font-weight: 400;
			color: #1C211D;
			line-height: 44rpx;
			margin-right: 50rpx;
		}
		.common-children-title-on {
			font-weight: 500;
		}
	}
	.common-head-more {
		width: 20rpx;
		height: 32rpx;
		image {
			width: 20rpx;
			height: 32rpx;
		}
	}
}
.search-list-content {
	padding: 0 30rpx;
}
.search-list-data {
	// margin-top: 30rpx;
}
.recommend-title {
	font-size: 36rpx;
	font-weight: 500;
	color: #2C2C2C;
	line-height: 50rpx;
	margin-top: 40rpx;
}
.servie-introduce {
	background: #FFFFFF;
	box-shadow: 4rpx 4rpx 50rpx 0rpx rgba(125,124,116,0.1);
	border-radius: 12rpx;
	padding: 40rpx 30rpx;
	font-size: 28rpx;
	font-weight: 400;
	color: #323232;
	line-height: 42rpx;
	margin-top: 20rpx;
}
.servie-label {
	background: #FFF9CD;
	border-radius: 32rpx;
	font-size: 28rpx;
	font-weight: 400;
	color: #323232;
	line-height: 40rpx;
	padding: 12rpx 30rpx;
	margin-top: 30rpx;
	width: fit-content;
	margin-bottom: 20rpx;
}
.head-wrapper {
		z-index: 999;
		display: flex;
		align-items: center;
		position: fixed;
		left: 30rpx;
		top: 0;
		/* #ifdef MP */
		height: 43px;
		/* #endif */
		/* #ifdef H5 */
		height: 114rpx;
		/* #endif */
	}
	.head-menu {
		display: flex;
		align-items: center;
		height: 54rpx;
		width: 140rpx;
		background: rgba(0, 0, 0, .25);
		border-radius: 27rpx;
		.iconfont {
			flex: 1;
			text-align: center;
			color: #fff;
			box-sizing: border-box;
			&.icon-xiangzuo {
				border-right: 1px solid #fff;
			}
		}
	}
	.head-title {
		font-size: 36rpx;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 36rpx;
		margin-left: 120rpx;
		white-space: nowrap;
	}
	
.popup_user_contact {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0,0,0,0.5);
	.popup_user_contact_c { 
		width: 480rpx;
		margin: 20vh auto;
		background-color: #fff;
		border-radius: 20rpx;
		text-align: center;
		.popup_user_contact_h {
			padding: 30rpx 30rpx 80rpx;
			border-bottom: 1rpx solid #DDDDDD;
			.popup_user_contact_t {
				font-size: 34rpx;
				font-weight: 400;
				color: #2C332D;
				line-height: 48rpx;
			}
			.popup_user_contact_u{
				font-size: 28rpx;
				font-weight: 500;
				color: #323232;
				line-height: 40rpx;
				margin-top: 32rpx;
				text {
					color: #F73D3B;
				}
			}
		}
		.popup_user_contact_b {
			padding: 20rpx 0;
			text-align: center;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			.popup_user_contact_close {
				font-size: 28rpx;
				font-weight: 400;
				color: #666764;
				line-height: 40rpx;
				flex: 1;
			}
			.popup_user_contact_copy {
				font-size: 28rpx;
				font-weight: 400;
				color: #323232;
				line-height: 40rpx;
				border-left: 1rpx solid #DDDDDD;
				flex: 1;
			}
		}
	}
}
	.navTabBox{
		background: #fff;
		// height: 90rpx;
		// border-bottom: 1px solid #000;
		.longTab{
			display: flex;
			text-align: center;
			padding: 20rpx 0;
			.tab-item{
				width: 50%;
				display: inline-block;
				line-height: 44rpx;
				position: relative;
				text{
					position: relative;
					display: inline-block;
					font-size: 32rpx;
					color: #1C211D;
				}
			}
			.tab-item:first-child {
				border-right: 1px solid #000;
			}
			.tab-item.on{
				color: var(--view-theme);
				text{
					font-size: 36rpx;
					font-weight: bold;
				}
			}
		}
	}
	.service_settle_btn {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		.service_settle_button {
			background-color: #FFE60F;
			width: fit-content;
			margin: 0 auto 50rpx;
			padding: 20rpx 100rpx;
			border-radius: 30rpx;
		}
	}
	.empty-box {
		margin-top: 0!important;
	}
	// 升级VIP弹窗
	.user_vip_back {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.5);
	}
	.user_vip_content {
		background-color: #fff;
		position: fixed;
		top: 30%;
		left: 50rpx;
		right: 50rpx;
		// margin: 50% 50rpx 0;
		border-radius: 30rpx;
		padding: 30rpx;
		text-align: center;
		.user_vip_close {
			position: absolute;
			right: 10rpx;
			top: 10rpx;
			image {
				width: 70rpx;
				height: 70rpx;
			}
		}
		.user_vip_icon {
			margin: 0 auto;
			image {
				width: 140rpx;
				height: 130rpx;
				margin: 0 auto;
				display: block;
			}
		}
		.user_vip_tit  {
			margin-top: 20rpx;
		}
		.user_vip_messag {
			font-size: 32rpx;
			margin-top: 30rpx;
		}
		.user_vip_btn {
			font-weight: bold;
			background-color: #FDE515;
			display: inline-block;
			padding: 10rpx 50rpx;
			border-radius: 10rpx;
			margin-top: 30rpx;
			font-size: 42rpx;
		}
	}
// 发布服务弹窗
.add_community {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0,0,0,0.5);
	z-index: 10;
	.add_community_content {
		background-color: #fff;
		position: fixed;
		top: 300rpx;
		left: 50rpx;
		right: 50rpx;
		border-radius: 30rpx;
		padding: 30rpx;
		text-align: center;
		z-index: 11;
	}
	.add_community_close {
		position: absolute;
		right: 30rpx;
		top: 50rpx;
		image {
			width: 50rpx;
			height: 50rpx;
		}
	}
	.add_community_icon  {
		image {
			width: 100rpx;
			height: 100rpx;
		}
	}
	.add_community_select {
		/* display: flex;
		align-items: center;
		justify-content: space-between; */
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		grid-gap: 20rpx;
		.add_community_b {
			background-color: #FEE612;
			border-radius: 10rpx;
			padding: 10rpx 0;
			font-size: 30rpx;
			font-weight: bold;
			margin-top: 30rpx;
		}
	}
	.add_community_tit {
		font-size: 36rpx;
		font-weight: bold;
		margin-top: 50rpx;
		text-align: center;
	}
	.add_community_key {
		text-align: left;
		font-size: 32rpx;
	}
	.add_community_pro {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		margin-top: 30rpx;
		grid-gap: 10rpx;
		.add_community_item {
			border: 1px solid #ccc;
			border-radius: 10rpx;
			padding: 20rpx 10rpx;
			.add_community_price {
				color: #EFBE18;
				font-size: 38rpx;
				font-weight: bold;
				text {
					font-size: 28rpx;
				}
			}
		}
		.add_community_item_on {
			background-color: #FFE103;
			.add_community_price {
				color: #000;
			}
		}
	}
	.add_community_btn {
		width: fit-content;
		margin: 50rpx auto 0;
		font-size: 42rpx;
		font-weight: bold;
		background-color: #FEE612;
		padding: 20rpx 50rpx;
		border-radius: 50rpx;
	}
}
// 发布服务弹窗end
</style>
